<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="shortcut icon" href="fyicon.ico">
    <meta name="format-detection" content="telephone=no" >
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>飞扬报修系统 </title>
<link href="__PUBLIC__/css/bootstrap.css" rel="stylesheet">
<link href="__PUBLIC__/css/style.css" rel="stylesheet">

<script type="text/javascript" src="__PUBLIC__/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/bootstrap.min.js"></script>
<!--[if lt IE 9]><script src="../../docs-assets/js/ie8-responsive-file-warning.js"></script><![endif]-->

<!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
  <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
</head>

<body>
<input type="hidden" id="token" value="@#$_GET['token']#@">
 <div class="navbar navbar-fixed-bottom navbar-inverse" role="navigation">
       <div class="container">   
       	  <ul class="nav nav-pills">
       	   <li><a href="__APP__/Home/StaffPage/add?token=@#$_GET['token']#@">一键接单</a></li>
            <li class="active"><a href="__APP__/Home/StaffPage/not?token=@#$_GET['token']#@">查看订单</a></li>
            <li><a href="__APP__/Home/AccountPage/logout">退出</a></li>
          </ul>
       </div>
    </div>
<div class="container1">
<br><center><h3>我的维修单</h3></center>
	<ul class="nav nav-tabs">
	  <li class="active"><a href="__APP__/Home/StaffPage/not?token=@#$_GET['token']#@">未完成(@#$count_not#@)</a></li>
	  <li><a href="__APP__/Home/StaffPage/has?token=@#$_GET['token']#@">已完成(@#$count_has#@)</a></li>
	</ul>
	<foreach name="info" item="vo">
	<div class="jumbotron"><!--每一个订单-->
    	<p class="text-success">订单号：@#$vo.number#@</p><!--订单号-->
    	<hr>
        <p>订单状态：<if condition="$vo.status eq 1">
						待确认接单						
						<elseif condition="$vo.status eq 2" />
						用户已取消该订单
						<elseif condition="$vo.status eq 3" />
						待维修
						<elseif condition="$vo.status eq 4" />
						该订单已完成
						</if></p>
        <p>客户姓名：@#$vo.name#@</p>
        <p>联系方式：<span>+86@#$vo.phone#@</span></p>
    	<p>电脑信息：@#$vo.brand#@@#$vo.model#@-@#$vo.buy_time|date="Ym",####@年购买</p>
		<p>报修时间：@#$vo.time|date='Y年m月d日 H:i',####@</p>
      	<p>故障信息：@#$vo.description#@</p>

  		<hr><p><div align="right"> 
  		   <span id="error_@#$vo.order_id#@" class="text-danger"></span>
		<if condition="$vo.status eq 1" >		
		<span class="refuse_order" ajaxid="@#$vo.order_id#@" staff-id="@#$vo.staff_id#@">
		   
		<button class="btn btn-sm btn-default" id="refuse_order_@#$vo.order_id#@" type="button">无法接单</button>
		</span>
		<span class="accept_order" ajaxid="@#$vo.order_id#@">
		   
		<button class="btn btn-sm btn-success" id="accept_order_@#$vo.order_id#@" type="button">我要接单</button>
		</span>
		</if>
    	</div></p>
	  </div>
    </br>
    </foreach>   

    <div class=\"pageNav"\>@#$page#@</div> <br>
</div> 
    <!-- Modal -->
        <div class="modal fade" id="refuse_reason" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
          <div class="modal-dialog">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h3 class="modal-title" id="myModalLabel">填写拒绝理由</h3>
              </div>
              <div class="modal-body">
              <div id="add_computer">
                  <input type="hidden" id="refuse_staff_id" value="" />
                  <input type="hidden" id="refuse_order_id" value="" />
                
                <p><input class="form-control"  type="text" name="reason" id="reason" placeholder="拒绝理由">
                  <div id="error_reason" class="text-danger"> ！理由不能为空</div></p>
                <div id="error_reason_ajax" class="text-danger"></div></p>
                <p><button class="btn-info btn btn-primary btn-block" type="button" id="submit_new_refuse">确认拒绝</button></p>
                
                </div>            
              </div>
            </div><!-- /.modal-content -->
          </div><!-- /.modal-dialog -->
        </div><!-- /.modal -->
<script type="text/javascript">

$(document).ready(function(){
	var token=$("#token").val();
	//接单
	$("#error_reason").hide();
	$(".accept_order").on("click",function(){	
			var order_id=$(this).attr('ajaxid');
			$("#accept_order_"+order_id).text('处理中..');
			$.post("__APP__/Home/Handle/accept?token="+token, {order_id:order_id},//取消的订单号
				function(data){
					if(data.status==0){
						$("#accept_order_"+order_id).text('接单失败,请重试');
						//document.location.reload("__APP__/Home/Handle/staffnot");
					}else{
						$("#accept_order_"+order_id).text('接单成功');
						window.location.reload("__APP__/Home/StaffPage/not?token="+token);//重新加载网页
					}
			});
	});
	//不接单
	$(".refuse_order").on("click",function(){	
		var order_id=$(this).attr('ajaxid');
		var refuse_order_id=$(this).attr('ajaxid');
		var staff_id=$(this).attr('staff-id');
		$("#refuse_order_"+order_id).text('处理中...');
		$.post("__APP__/Home/Handle/check_refuse?token="+token,{order_id:order_id,refuse_order_id:refuse_order_id,staff_id:staff_id},
			function(data){
				if(data.status==0){
				    $("#refuse_order_id").val(order_id);
				    $("#refuse_staff_id").val(staff_id);
				    $("#refuse_reason").modal();
				   $("#refuse_order_"+order_id).text('无法接单');
				}else{
				    $("#refuse_order_"+order_id).text('无法接单');
					  $("#error_"+order_id).text(data.status+":"+data.des);
                    //document.location.reload("__APP__/Home/Handle/staffnot");
				}
			});
	});
	$("#submit_new_refuse").on("click",function(){
    var order_id=$("#refuse_order_id").val();
    var staff_id=$("#refuse_staff_id").val();
    var reason=$("#reason").val();
    //判断用户是否内容都输入了
    if(reason==""){$("#error_reason").show();} else {$("#error_reason").hide();}
    if(reason!=""){
      //若均填写隐藏提示信息
      $("#error_reason").hide();
      $("#submit_new_refuse").text('处理中..');
      $.post("__APP__/Home/Handle/refuse?token="+token, {order_id:order_id,staff_id:staff_id,reason:reason},
        function(data){
         if(data.status==0){
         $("#submit_new_refuse").text('拒绝成功!');
location.href="__APP__/Home/StaffPage/not?token="+token;
        }else{
          $("#submit_new_computer").text('确认拒绝');
          $("#error_reason_ajax").text(data.des);
          $("#reason").val("");
           $("#refuse_order_id").val("");
           $("#refuse_staff_id").val("");
        }
      });
    }
  });

});



</script>
</body>
</html>
